<%@ taglib prefix="from" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
    var ctx="${ctx}";
    var patientId='${clinicMaster.patientId}';
    var clinicId='${clinicMaster.id}';
    var my_register;
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

        function addWin(clinicId,id){
            var url=ctx+'/doctor/pregnantVisit/findById';
            var title='';
            if(id!=''&&id){
                //修改
                url+="?id="+id+"&clinicId="+clinicId;
                title='专家鉴定项目';
            }
            //type为1是复诊记录type为2是专家鉴定
            url+="&type=2";
             my_register=layer.open({
                title:title,
                type: 2,
                area: ['1080px', '60%'],
                content: url,
                btn: ['确定', '取消'],
                yes:function(index,layero){
                    butType(index,layero);
                }
            });
        }

        function butType(index,layero){
            //if ($('#inputForm').parsley().validate()) {
            var form = layer.getChildFrame('form', index);
            if (form.parsley().validate()) {
                $.ajax({
                    type: "POST",
                    data:form.serialize(),
                    url: "${ctx}/doctor/pregnantVisit/save",
                    dataType: "json",
                    success: function (data) {
                        toastr.success(data.data);
                        layer.close(my_register);
                        loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantVisit/expertIndex?clinicId='+clinicId)
                    },
                    error: function (data) {
                        toastr.error('网络连接错误,请检查网络');
                    }
                });
            }
            return false;
        }
        function delRecord(id){
            $.ajax({
                type: "GET",
                url: "${ctx}/doctor/pregnantVisit/delete?id="+id,
                dataType: "json",
                success: function (data) {
                    toastr.success(data.data);
                    loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantVisit/index?clinicId='+clinicId)
                },
                error: function (data) {
                    toastr.error('网络连接错误,请检查网络');
                }
            });
            return false;
        }
    function confirmExtend(str, id) {
        layer.confirm(str, {
            skin: 'layui-layer-molv',
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            delRecord(id);
            layer.close(index);
        }, function (index) {
            layer.close(index);
        });
    }
    /**
     *form表单提交load
     * @param divId
     * @param formId
     * @param url
     */
    function loadDivForm(divId, formId, url) {
        var title='';
        var num='';
        if($("#searchGestationalTitle").val()!=''&&$("#searchGestationalTitle").val())
            title=$("#searchGestationalTitle").val();
        url = url + '?' + $("#" + formId).serialize()+'clinicId='+clinicId+'&pageNo='+$("#pageNo").val()+'&pageSize='+$("#pageSize").val()+'&title='+title;
        if($("#searchNum").val()!=''&&$("#searchNum").val()){
            num=$("#searchNum").val();
            url+="&num="+num;
        }
        setTimeout(loadDiv(divId, url), 300);
        return false;
    }
</script>

    <div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantRecords/index?clinicId='+clinicId)">孕妇初诊记录</a>
                </li>
                <li>
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantVisit/index?clinicId='+clinicId)">孕妇复诊记录</a>
                </li>
                <li class="active">
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantVisit/expertIndex?clinicId='+clinicId)">专家鉴定</a>
                </li>
                <li>
                    <a href="#"   onclick="loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/pregnantNatalcRecord/index?clinicId='+clinicId)">产后42天体检表</a>
                </li>

            </ul>
            <div class="panel-body">
                <div class="table-responsive no-border">
                    <div class="datatable-top">
                        <div class="pull-left">
                            <form:form id="searchForm" modelAttribute="pregnantVisit"  onsubmit="return loadDivForm('rigthDoctorCenterDiv','searchFormDict','${ctx}/doctor/pregnantVisit/expertIndex');" method="post" class="form-inline">
                                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                <label>复诊记录:</label><sys:select isNull="1"
                                                                lists="${fns:getDictList('PREGNANT_VISIT_RECORDS')}"
                                                                className="form-control" name="searchGestationalTitle"></sys:select>
                                <label>就诊次数:</label><input type="number" min="0" max="99" name="searchNum" id="searchNum"
                                                           class="form-control">
                                &nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                            </form:form>
                        </div>
                    </div>
                    <table id="contentTable" class="table table-bordered table-striped mg-t datatable">
                        <thead>
                            <tr>
                                    <th>门诊号</th>
                                    <th>复诊记录</th>
                                    <th>孕周</th>
                                    <th>就诊次数</th>
                                    <th>检查日期</th>
                                    <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${page.list}" var="pregnantVisit">
                            <tr>
                                    <td> ${pregnantVisit.clinicNo}</td>
                                    <td> ${fns:getDictLabel(pregnantVisit.gestationalTitle,"PREGNANT_VISIT_RECORDS" ,"" )}</td>
                                    <td> ${pregnantVisit.gestationalWeeks}</td>
                                    <td> ${pregnantVisit.visitInt}</td>
                                    <td> <fmt:formatDate value="${pregnantVisit.testingDatetime}" pattern="yyyy-MM-dd  HH:mm:ss" /></td>
                                <td>
                                    <a href="#" onclick="addWin('${pregnantVisit.clinicId}','${pregnantVisit.id}')" class="btn btn-success btn-xs">鉴定</a>
                                </td>
                            </tr>
                        </c:forEach>

                    </table>
                    <div class="pagination">${page}</div>
                </div>
            </div>
        </div>
    </div>